<?php 
namespace Home\Controller;


class ShowController extends SimpleController {
    public function _initialize(){

    }

    public function index()
    {
        $people_data = M('experience')->field('uid,count(uid)')->order('count(uid) desc')->limit(50)->group('uid')->select();
        $user_info = array();
        foreach ($people_data as $key => $val) {
            $model = M('user')->field('name')->where('id = '.$val['uid'])->find();
            $model_path = M('user_info')->field('thumbpath,fans,signature,exp,uid')->where('uid = '.$val['uid'])->find();

            $exp = $model_path['exp'];
            $level = (($exp - $exp%100)/100 + 1);
            $exp = $exp%100;
            switch ($level) {
                case '1':
                    $design = '初学乍练 LV1';
                    break;
                case '2':
                    $design = '登堂入室 LV2';
                    break;
                case '3':
                    $design = '初窥堂奥 LV3';
                    break;
                case '4':
                    $design = '略有小成 LV4';
                    break;
                case '5':
                    $design = '渐入佳境 LV5';
                    break;
                case '6':
                    $design = '炉火纯青 LV6';
                    break;
                case '7':
                    $design = '自成一派 LV7';
                    break;
                case '8':
                    $design = '功行圆满 LV8';
                    break;
                case '9':
                    $design = '登峰造极 LV9';
                    break;
                default:
                    $design = '神功绝世 LV10';
                    break;
            }
            $model_path['design'] = $design;
            $info = array_merge($model,$model_path);
            $info2['user_info'] = $info;
            $info2['user_info'][count] = $val['count(uid)'];
            // $user_info[] = $info;
            $model = M('experience')->field('id,title,g_count,collector')->limit(4)->where('uid = '.$val['uid'])->select();
            $model2['experience'] = $model;
            $info = array_merge($model2,$info2);
            
            $user_info[] = $info;
        }
        // echo '<pre>';
        // print_r($user_info);
        // exit;
        $this->assign('show_man',$user_info);
        $this->assign('title','分享达人');
        $this->display('Show/index');
    }
}
